{% assign data = section.settings %}
<div class="block_image_text" style="--text-color: {{data.text_color}};--btn-color: {{data.btn_color}};--btn-bg: {{data.btn_bg}};--bg-color: {{data.bg_color}};--radius: {{data.radius}}px;">
  <div class="container_wrapper">
    <div class="content flex md:flex-row flex-col {{data.img_position}}">
      <div class="text_box flex items-center">
        <div class="text_content">

          {% if data.title != '' %}
            <div class="text_title public_title mt-2.5">{{data.title}}</div>
          {% endif %}
          {% if data.detail != '' %}
            <div class="text_detail mt-4">{{data.detail}}</div>
          {% endif %}
          {% if data.btn_text != '' %}
            <div class="btn_wrap mt-8">
              <a class="public_btn btn_anime" href="{{data.link | setUrlDataFrom:data_from}}">
                {{data.btn_text}}
              </a>
            </div>
          {% endif %}
        </div>

      </div>
      <div class="img_box relative flex-shrink-0">
        {% include 'lazy_img',src: data.image.src, alt: data.image.alt %}
        {% for block in section.blocks %}
          {% get_product product_id = {block.good.id}  %}
          {% if product.size > 0 %}
            <div class="look_hotspot absolute" style="--x: {{block.hotspotX}}%;--y: {{block.hotspotY}}%;">
              <button class="look_hotspot_btn" data-handle="{{ product.handle }}" data-from="{{data_from}}">
                <span></span>
              </button>
              <div class="lookbook_shop_product">
                <div class="lookbook_title line-clamp">
                  {{product.title}}
                </div>
                <div class="lookbook_price">
                  {% if product.variant.price < 0 %}
                    <span class="general-price">{{ "88.88" | money }}</span>
                  {% else %}
                    <span class="general-price">{{ product.variant.price | money }}</span>
                  {% endif %}
                  {% if goodProduct1.variant.compare_at_price != "0" and  goodProduct1.variant.price < goodProduct1.variant.compare_at_price %}
                    <span class="general-oldprice">{{ goodProduct1.variant.compare_at_price | default : "88.88" | money }}</span>
                  {% endif %}
                </div>
              </div>
            </div>
          {% endif %}
        {% endfor %}
      </div>
    </div>
  </div>
</div>

<script>
  $(function() {
    $('.block_image_text .look_hotspot .look_hotspot_btn').on('click', function() {
      let handle = $(this).data('handle')
      let data_from = $(this).data('from')
      moi.popupProductPicture({handle, data_from});
    })
  })
</script>

{% schema %}
{
	"class": "block_image_text",
	"is_global": false,
	"icon": "icon-tuwen",
	"name": {
		"zh_CN": "图文",
		"en_US": "Image and text"
	},
	"max_blocks": 4,
	"blocks": [
		{
			"name": {
				"zh_CN": "商品设置"
			},
			"type": "item",
			"settings": [
				{
					"type": "card_product",
					"label": {
						"zh_CN": "选择商品",
						"en_US": "Select product"
					},
					"default": {
						"id": "",
						"title": ""
					},
					"id": "good"
				},
				{
					"type": "card_slider",
					"label": {
						"zh_CN": "横向位置"
					},
					"id": "hotspotX",
					"max": 90,
					"min": 10,
					"unit": "%",
					"default": 50
				},
				{
					"type": "card_slider",
					"label": {
						"zh_CN": "纵向位置"
					},
					"id": "hotspotY",
					"max": 90,
					"min": 10,
					"unit": "%",
					"default": 50
				}
			]
		}
	],
	"settings": [
		{
			"type": "card_header",
			"label": {
				"zh_CN": "设置",
				"en_US": "Settings"
			}
		},
		{
			"type": "card_slider",
			"label": {
				"zh_CN": "圆角"
			},
			"id": "radius",
			"max": 50,
			"min": 0,
			"unit": "px",
			"default": 30
		},
		{
			"type": "card_image",
			"label": {
				"zh_CN": "图片",
				"en_US": "Image"
			},
			"default": {
				"src": "",
				"alt": ""
			},
			"info": {
				"zh_CN": "建议尺寸：1000*1000px",
				"en_US": "Suggested size: 1000 x 1000px"
			},
			"id": "image"
		},
		{
			"type": "card_select",
			"label": {
				"zh_CN": "图片位置(PC)",
				"en_US": "Image location (PC)"
			},
			"default": "left",
			"id": "img_position",
			"option": [
				{
					"label": {
						"zh_CN": "居左",
						"en_US": "To the left"
					},
					"value": "img_left"
				},
				{
					"label": {
						"zh_CN": "居右",
						"en_US": "To the right"
					},
					"value": "img_right"
				}
			]
		},
		{
			"type": "card_input",
			"label": {
				"zh_CN": "标题",
				"en_US": "Title"
			},
			"default": "",
			"id": "title"
		},
		{
			"type": "card_text_editor",
			"label": {
				"zh_CN": "描述",
				"en_US": "Description"
			},
			"id": "detail",
			"default": ""
		},
		{
			"type": "card_input",
			"label": {
				"zh_CN": "按钮文字",
				"en_US": "Button text"
			},
			"default": "",
			"id": "btn_text"
		},
		{
			"type": "card_page_link",
			"label": {
				"zh_CN": "跳转链接",
				"en_US": "Jump links"
			},
			"default": {
				"type": "",
				"title": "",
				"url": ""
			},
			"id": "link"
		},
		{
			"type": "card_header",
			"label": {
				"zh_CN": "颜色设置",
				"en_US": "Color Settings"
			}
		},
		{
			"type": "card_color",
			"id": "bg_color",
			"label": {
				"zh_CN": "背景颜色",
				"en_US": "Background color"
			},
			"default": "#fdf9ee"
		},
		{
			"type": "card_color",
			"id": "text_color",
			"label": {
				"zh_CN": "文本颜色",
				"en_US": "Text color"
			},
			"default": "#000"
		},
		{
			"type": "card_color",
			"id": "btn_color",
			"label": {
				"zh_CN": "按钮文字颜色",
				"en_US": "Button text color"
			},
			"default": "#fff"
		},
		{
			"type": "card_color",
			"id": "btn_bg",
			"label": {
				"zh_CN": "按钮背景颜色",
				"en_US": "Button background color"
			},
			"default": "#000"
		},
		{
			"type": "card_header",
			"label": {
				"zh_CN": "内容",
				"en_US": "Content"
			}
		}
	],
	"default": {
		"settings": {
			"radius": 30,
			"image": {
				"src": "",
				"alt": ""
			},
			"img_position": "img_left",
			"title": "Shop the Look",
			"detail": "Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.",
			"btn_text": "Shop Now",
			"link": {
				"type": "",
				"title": "",
				"url": ""
			},
			"bg_color": "#fdf9ee",
			"text_color": "#000",
			"btn_color": "#fff",
			"btn_bg": "#000"
		},
		"blocks": [
			{
				"good": {
					"id": "",
					"title": ""
				},
				"hotspotX": 50,
				"hotspotY": 50,
				"block_type": "item"
			},
			{
				"good": {
					"id": "",
					"title": ""
				},
				"hotspotX": 30,
				"hotspotY": 60,
				"block_type": "item"
			}
		]
	}
}
{% endschema %}